package com.rome.hotel.data.service.impl;

import java.util.List;
import com.rome.hotel.common.utils.DateUtils;
import com.rome.hotel.data.domain.HotelUser;
import com.rome.hotel.data.utils.RegexUtils;
import io.jsonwebtoken.lang.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.rome.hotel.data.mapper.HotelRoomTypeMapper;
import com.rome.hotel.data.domain.HotelRoomType;
import com.rome.hotel.data.service.IHotelRoomTypeService;

/**
 * 房间类型Service业务层处理
 * 
 * @author rome
 * @date 2023-12-21
 */
@Service
public class HotelRoomTypeServiceImpl implements IHotelRoomTypeService 
{
    @Autowired
    private HotelRoomTypeMapper hotelRoomTypeMapper;

    /**
     * 查询房间类型
     * 
     * @param roomTypeId 房间类型主键
     * @return 房间类型
     */
    @Override
    public HotelRoomType selectHotelRoomTypeByRoomTypeId(Long roomTypeId)
    {
        return hotelRoomTypeMapper.selectHotelRoomTypeByRoomTypeId(roomTypeId);
    }

    /**
     * 查询房间类型列表
     * 
     * @param hotelRoomType 房间类型
     * @return 房间类型
     */
    @Override
    public List<HotelRoomType> selectHotelRoomTypeList(HotelRoomType hotelRoomType)
    {
        return hotelRoomTypeMapper.selectHotelRoomTypeList(hotelRoomType);
    }

    /**
     * 新增房间类型
     * 
     * @param hotelRoomType 房间类型
     * @return 结果
     */
    @Override
    public int insertHotelRoomType(HotelRoomType hotelRoomType)
    {
//        1.防御性编程
        Assert.notNull(hotelRoomType,"参数为空");
        Assert.state(RegexUtils.testStringNoThreeBai(hotelRoomType.getRoomTypeName())&&RegexUtils.testStringNoThreeBai(hotelRoomType.getRoomTypeDescription()),"内容1到300位");
        hotelRoomType.setCreateTime(DateUtils.getNowDate());
        return hotelRoomTypeMapper.insertHotelRoomType(hotelRoomType);
    }

    /**
     * 修改房间类型
     * 
     * @param hotelRoomType 房间类型
     * @return 结果
     */
    @Override
    public int updateHotelRoomType(HotelRoomType hotelRoomType)
    {
//        1.防御性编程
        Assert.notNull(hotelRoomType,"参数为空");
        Assert.state(RegexUtils.testStringNoThreeBai(hotelRoomType.getRoomTypeName())&&RegexUtils.testStringNoThreeBai(hotelRoomType.getRoomTypeDescription()),"内容1到300位");
        return hotelRoomTypeMapper.updateHotelRoomType(hotelRoomType);
    }

    /**
     * 批量删除房间类型
     * 
     * @param roomTypeIds 需要删除的房间类型主键
     * @return 结果
     */
    @Override
    public int deleteHotelRoomTypeByRoomTypeIds(Long[] roomTypeIds)
    {
        for (Long id:roomTypeIds
        ) {

            Assert.notNull(hotelRoomTypeMapper.selectHotelRoomTypeByRoomTypeId(id),"参数异常");
        }
        return hotelRoomTypeMapper.deleteHotelRoomTypeByRoomTypeIds(roomTypeIds);
    }

    /**
     * 删除房间类型信息
     * 
     * @param roomTypeId 房间类型主键
     * @return 结果
     */
    @Override
    public int deleteHotelRoomTypeByRoomTypeId(Long roomTypeId)
    {
        //        1.防御性编程
        HotelRoomType hotelRoomType = hotelRoomTypeMapper.selectHotelRoomTypeByRoomTypeId(roomTypeId);
        Assert.notNull(hotelRoomType,"参数异常");
        return hotelRoomTypeMapper.deleteHotelRoomTypeByRoomTypeId(roomTypeId);
    }
}
